package com.my.control;

import java.util.List;
import java.util.Map;

import org.apache.struts2.interceptor.RequestAware;
import org.apache.struts2.interceptor.SessionAware;

import com.my.bean.Address;
import com.my.bean.Admin;
import com.my.bean.Order;
import com.my.bean.OrderAccepted;
import com.my.bean.OrderBack;
import com.my.bean.Part;
import com.my.bean.User;
import com.my.bo.AccountBo;
import com.my.bo.AddressBo;
import com.my.bo.OrderBo;
import com.my.bo.PartBo;
import com.my.util.PageBean;

public class BaseAction implements RequestAware, SessionAware {
	Map<String, Object> request;
	Map<String, Object> session;
	AccountBo accountbo;
	AddressBo addressbo;
	PartBo partbo;
	OrderBo orderbo;
	Integer pageNo;
	Admin admin;
	User user;
	Address address;
	Part part;
	Order order;
	OrderAccepted orderaccepted;
	OrderBack orderback;

	@Override
	public void setRequest(Map<String, Object> request) {
		this.request = request;
	}

	@Override
	public void setSession(Map<String, Object> session) {
		this.session = session;
	}

	public void setAccountbo(AccountBo accountbo) {
		this.accountbo = accountbo;
	}

	public void setAddressbo(AddressBo addressbo) {
		this.addressbo = addressbo;
	}

	public void setPartbo(PartBo partbo) {
		this.partbo = partbo;
	}

	public void setOrderbo(OrderBo orderbo) {
		this.orderbo = orderbo;
	}

	public Integer getPageNo() {
		return pageNo;
	}

	public void setPageNo(Integer pageNo) {
		this.pageNo = pageNo;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public Admin getAdmin() {
		return admin;
	}

	public void setAdmin(Admin admin) {
		this.admin = admin;
	}

	public Address getAddress() {
		return address;
	}

	public void setAddress(Address address) {
		this.address = address;
	}

	public Part getPart() {
		return part;
	}

	public void setPart(Part part) {
		this.part = part;
	}

	public Order getOrder() {
		return order;
	}

	public void setOrder(Order order) {
		this.order = order;
	}

	public OrderAccepted getOrderaccepted() {
		return orderaccepted;
	}

	public void setOrderaccepted(OrderAccepted orderaccepted) {
		this.orderaccepted = orderaccepted;
	}

	public OrderBack getOrderback() {
		return orderback;
	}

	public void setOrderback(OrderBack orderback) {
		this.orderback = orderback;
	}

	@SuppressWarnings("unchecked")
	public <T> PageBean<T> setPageBean(List<T> list, int totalRecords) {
		PageBean<T> pagebean = (PageBean<T>) request.get("pagebean");
		if (pagebean == null) {
			pagebean = new PageBean<T>();
			request.put("pagebean", pagebean);
		}
		pagebean.setPageNo(pageNo); // 设置当前页码
		pagebean.setPageSize(15);// 每页显示15个
		pagebean.setTotalRecords(totalRecords);
		pagebean.setList(list);
		return pagebean;
	}
}
